<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title>贷款</title>
		<link rel="stylesheet" type="text/css" href="${BASE_PATH}/static/lib/layui/css/layui.css" />
	</head>

	<body style="margin: 10px 10px 0 10px;">
		<div class="layui-tab">
			<ul class="layui-tab-title">
				<li class="layui-this">先息后本</li>
				<li>等额本息</li>
			</ul>
			<div class="layui-tab-content">
				<div class="layui-tab-item layui-show">
					<form class="layui-form">
					<input type="hidden" name="tyUserId" value="${yhuser.yhUserId}"/>
					<input type="hidden" name="tyUserName" value="${yhuser.yhUserName}"/>
						<div class="layui-form-item" pane="">
							<label class="layui-form-label">还款方式</label>
							<div class="layui-input-block">
								<input type="radio" lay-filter="Interest1" name="loanType" value="0" title="日息" checked>
								<input type="radio" lay-filter="Interest" name="loanType" value="2" title="月息">
							</div>
						</div>
						<div id="Interest" class="layui-form-item" style="display: none;">
							<label class="layui-form-label">借款利息<span class="x-red" style="color:#ff0000;">%</span></label>
							<div class="layui-input-inline">
								<input type="number" name="interest" value="0" lay-verify="pass" placeholder="请输入借款利息" autocomplete="off" class="layui-input">
							</div>
						</div>
						<div class="layui-form-item">
							<label class="layui-form-label">借款金额</label>
							<div class="layui-input-inline">
								<input type="number" name="loanMoney" value="0" lay-verify="pass" placeholder="请输入实际借款金额" autocomplete="off" class="layui-input">
							</div>
							<!--<div class="layui-form-mid layui-word-aux">请填写</div>-->
						</div>
						<div class="layui-form-item">
							<label class="layui-form-label">合同金额</label>
							<div class="layui-input-inline">
								<input type="number" name="contractMoney" value="0" lay-verify="pass" placeholder="请输入实际合同签订金额" autocomplete="off" class="layui-input">
							</div>
							<!--<div class="layui-form-mid layui-word-aux">请填写</div>-->
						</div>
						<div class="layui-form-item">
							<div class="layui-inline">
								<label class="layui-form-label">开始时间</label>
								<div class="layui-input-inline">
									<input type="text" name="str" class="layui-input" id="newDate" placeholder="请选择开始时间">
								</div>
								<!--<div class="layui-form-mid layui-word-aux">请填写</div>-->
							</div>
						</div>
						<div class="layui-form-item">
							<div class="layui-inline">
								<label class="layui-form-label">结束时间</label>
								<div class="layui-input-inline">
									<input type="text" name="sto" class="layui-input" id="oldDate" placeholder="请选择结束时间">
								</div>
								<!--<div class="layui-form-mid layui-word-aux">请填写</div>-->
							</div>
						</div>

						<div class="layui-form-item">
							<label class="layui-form-label">其他成本费用</label>
							<div class="layui-input-block">
								<input lay-filter="aa" type="checkbox" name="" title="家访费用">
								<input id="aaa" type="number" name="homeVisitsMoney" value="0" lay-verify="pass" placeholder="请输入家访费用" autocomplete="off" class="layui-input" style="width: 150px;display: none;">
								<input lay-filter="bb" type="checkbox" name="" title="中介费用">
								<input id="bbb" type="number" name="intermediary" value="0" lay-verify="pass" placeholder="请输入中介费用" autocomplete="off" class="layui-input" style="width: 150px;display: none;">
							</div>
						</div>
						<div class="layui-form-item">
							<label class="layui-form-label">保证金费用</label>
							<div class="layui-input-inline">
								<input type="number" name="bond" lay-verify="pass" value="0" placeholder="请输入保证金" autocomplete="off" class="layui-input">
							</div>
							<!--<div class="layui-form-mid layui-word-aux">请填写</div>-->
						</div>
						<div class="layui-form-item">
							<div class="layui-input-block">
								<a class="layui-btn" lay-submit="" lay-filter="xxhb"><i class="layui-icon">&#x1005;</i>确定</a>
							</div>
						</div>
					</form>

				</div>
				<div class="layui-tab-item">
					<form class="layui-form" action="">
					<input type="hidden" name="tyUserId" value="${yhuser.yhUserId}"/>
					<input type="hidden" name="tyUserName" value="${yhuser.yhUserName}"/>
						<div class="layui-form-item" pane="">
							<label class="layui-form-label">还款方式</label>
							<div class="layui-input-block">
								<input type="radio" name="loanType" value="0" title="日息" checked="">
								<input type="radio" name="loanType" value="1" title="周息">
							</div>
						</div>
						<div id="lixi" class="layui-form-item">
							<label class="layui-form-label">借款利息
							<span class="x-red" style="color:#ff0000;">%</span></label>
							<div class="layui-input-inline">
								<input style="width:90%;" type="number" name="interest" value="" lay-verify="pass" placeholder="请输入借款利息" autocomplete="off" class="layui-input">
							</div>
						</div>
						<div class="layui-form-item">
							<label class="layui-form-label">借款金额</label>
							<div class="layui-input-inline">
								<input type="number" name="loanMoney" value="0" lay-verify="pass" placeholder="请输入实际借款金额" autocomplete="off" class="layui-input">
							</div>
							<!--<div class="layui-form-mid layui-word-aux">请填写</div>-->
						</div>
						<div class="layui-form-item">
							<label class="layui-form-label">合同金额</label>
							<div class="layui-input-inline">
								<input type="number" name="contractMoney" value="0" lay-verify="pass" placeholder="请输入实际合同签订金额" autocomplete="off" class="layui-input">
							</div>
							<!--<div class="layui-form-mid layui-word-aux">请填写</div>-->
						</div>
						<div class="layui-form-item">
							<div class="layui-inline">
								<label class="layui-form-label">开始时间</label>
								<div class="layui-input-inline">
									<input type="text" name="str" class="layui-input" id="newDate1" placeholder="请选择开始时间">
								</div>
								<!--<div class="layui-form-mid layui-word-aux">请填写</div>-->
							</div>
						</div>
						<div class="layui-form-item">
							<div class="layui-inline">
								<label class="layui-form-label">结束时间</label>
								<div class="layui-input-inline">
									<input type="text" name="sto" class="layui-input" id="oldDate1" placeholder="请选择结束时间">
								</div>
								<!--<div class="layui-form-mid layui-word-aux">请填写</div>-->
							</div>
						</div>

						<div class="layui-form-item">
							<label class="layui-form-label">其他成本费用</label>
							<div class="layui-input-block">
								<input lay-filter="cc" type="checkbox" name="aa" title="家访费用">
								<input id="ccc" type="number" name="homeVisitsMoney" value="0" lay-verify="pass" placeholder="请输入家访费用" autocomplete="off" class="layui-input" style="width: 150px;display: none;">
								<input lay-filter="dd" type="checkbox" name="bb" title="中介费用">
								<input id="ddd" type="number" name="intermediary" value="0" lay-verify="pass" placeholder="请输入中介费用" autocomplete="off" class="layui-input" style="width: 150px;display: none;">
							</div>
						</div>
						<div class="layui-form-item">
							<label class="layui-form-label">保证金费用</label>
							<div class="layui-input-inline">
								<input type="number" name="bond" lay-verify="pass" value="0" placeholder="请输入保证金" autocomplete="off" class="layui-input">
							</div>
							<!--<div class="layui-form-mid layui-word-aux">请填写</div>-->
						</div>
						<div class="layui-form-item">
							<div class="layui-input-block">
								<button class="layui-btn" lay-submit="" lay-filter="debx"><i class="layui-icon">&#x1005;</i>确定</button>
							</div>
						</div>
					</form>
				</div>
			</div>
		</div>
	</body>
	<script src="${BASE_PATH}/static/lib/layui/layui.js"></script>
	<script>
		layui.use(['form', 'layedit', 'laydate', 'jquery', 'table', 'element'], function() {
			var form = layui.form,
				layer = layui.layer;
			var $ = layui.jquery;
			var table = layui.table;
			var element = layui.element;
			var laydate = layui.laydate;

			laydate.render({
				elem: '#newDate',
				type: 'datetime'
			});
			laydate.render({
				elem: '#oldDate',
				type: 'datetime'
			});
			laydate.render({
				elem: '#newDate1',
				type: 'datetime'
			});
			laydate.render({
				elem: '#oldDate1',
				type: 'datetime'
			});
			
			
			form.on('radio(Interest)', function(data) {
				if(data.elem.checked == true) {
					document.getElementById("Interest").style.display = "block";
				}
			});form.on('radio(Interest1)', function(data) {
				if(data.elem.checked == true) {
					document.getElementById("Interest").style.display = "none";
				}
			});

			form.on('checkbox(aa)', function(data) {
				if(data.elem.checked == true) {
					document.getElementById("aaa").style.display = "block";
				} else {
					document.getElementById("aaa").style.display = "none";
				}
			});
			form.on('checkbox(bb)', function(data) {
				if(data.elem.checked == true) {
					document.getElementById("bbb").style.display = "block";
				} else {
					document.getElementById("bbb").style.display = "none";
				}
			});
			form.on('checkbox(cc)', function(data) {
				if(data.elem.checked == true) {
					document.getElementById("ccc").style.display = "block";
				} else {
					document.getElementById("ccc").style.display = "none";
				}
			});
			form.on('checkbox(dd)', function(data) {
				if(data.elem.checked == true) {
					document.getElementById("ddd").style.display = "block";
				} else {
					document.getElementById("ddd").style.display = "none";
				}
			});
			
			//先息后本
			form.on('submit(xxhb)', function(data) {
				$.ajax({
					type:'POST',
					url:'${BASE_PATH}/admin/user/ajax_add_loan_xxhb',
					data:data.field,
					success:function(res){
						if(res.success == true){
							alert(res.msg)
							parent.location.reload();
						}else if(res.code == 404){
							alert(res.msg)
							parent.location.reload();
						}
					}
				})
			});
			
			//等额本息
			form.on('submit(debx)', function(data) {
				$.ajax({
					type:'POST',
					url:'${BASE_PATH}/admin/user/ajax_add_loan_debx',
					data:data.field,
					success:function(res){
						if(res.success == true){
							alert(res.msg)
							parent.location.reload();
						}else if(res.code == 404){
							alert(res.msg)
							parent.location.reload();
						}
					}
				})
			});

		});
	</script>

</html>